<template>
  <div>
    <div>
      <div style="text-align: center; margin: 10px">
        {{ form.CheckTaskName }}
      </div>
      <div class="block-box">
        <div class="block-box_item">
          <eagle-cell-group :border="border">
            <eagle-input 
              label="检查类型"
              :value="
                form.CheckTypeName +
                (form.CheckType == 'ZCLX0002'
                  ? '(' + form.ItemTypeName + ')'
                  : '')
              "
              readonly
            ></eagle-input>

            <eagle-input
              label="检查企业"
              autosize
              type="textarea"
              rows="1"
              v-if="form.CPID == null"
              :value="form.EnterpriseName"
              readonly
              islink
              @click="goFromDeta()"
            ></eagle-input>
            <eagle-input
              label="任务发起人"
              :value="form.CreateChnName"
              readonly
            ></eagle-input>
            <eagle-input
              label="任务发起时间"
              :value="form.CreateDate"
              readonly
            ></eagle-input>
            <eagle-input
              label="检查人"
              v-if="form.Status == 30"
              :value="form.CheckNames"
              autosize
              type="textarea"
              rows="1"
              readonly
            ></eagle-input>
            <eagle-input
              label="检查时间段"
              :value="form.StartDate + '至' + form.EndDate"
              autosize
              type="textarea"
              rows="1"
              readonly
            ></eagle-input>
            <eagle-input
              label="检查要求"
              :value="form.CheckRequirement || '暂无检查要求'"
              autosize
              type="textarea"
              rows="1"
              readonly
            ></eagle-input>
			
          </eagle-cell-group>
        </div>
      </div>


    </div>
  </div>
</template>

<script>
import { getDateTime } from "@/utils/getDate";
import { Dialog } from "vant";
import { mapGetters } from "vuex";

// import { deepClone } from "@/utils";
export default {
  data() {
    return {
      baseUrl: process.env.VUE_APP_BASE_API,
      id: this.$route.query.id,
      TaskCTCode: this.$route.query.TaskCTCode,
      isDate: true,
      border: false,
	  filter: {
        id : this.$route.query.TaskId,
      },
      form: {
        Templates: [],
      },
    };
  },
  computed: {
    ...mapGetters(["CompanyCode"]),
  },
  created() {
    this.isDate = this.$route.query.isDate;
    this.geDetail();
  },
  methods: {

    goCheckBasis() {
      this.$router.push({
        path: "/OtherDanger/Classifys?hasPhoto=hasPhoto",
        query: { ctCode: this.form.CTCode, OriginType: 2 },
      });
    },
    // 随手拍
    goTakePhoto() {
      this.$router.push({
        path: "/OtherDanger/DangerCheckTaskDetailEdit",
        query: { ctCode: this.form.CTCode, originType: 3 },
      });
    },

    goCheckList() {
      this.$router.push(
        "/OtherDanger/DangerCheckTaskTemplateList?ctCode=" + this.form.CTCode
      );
    },

    // 获取详情
    geDetail() {
      if(this.TaskCTCode.startsWith("OCT")){
        let that = this;
        that.$axios
        .get("/OtherDangerCheckTaskJG/GetDetail",{params:that.filter})
        .then((res) => {
          that.form = res.data;
          that.form.StartDate = getDateTime(this.form.StartDate);
          that.form.EndDate = getDateTime(this.form.EndDate);
          that.form.CreateDate = getDateTime(this.form.CreateDate);
        });
      }
      else{
        let that = this;
        that.$axios
        .get("/DangerCheckTaskJG/GetDetail",{params:that.filter})
        .then((res) => {
          that.form = res.data;
          that.form.StartDate = getDateTime(this.form.StartDate);
          that.form.EndDate = getDateTime(this.form.EndDate);
          that.form.CreateDate = getDateTime(this.form.CreateDate);
        });
      }
      
    },

    goFromDeta() {
      this.$router.push("/BaseInfo?CompanyCode=" + this.form.EnterpriseCode);
    },

    goCheckResult(item) {
      if (item.Status < 10) {
        this.$router.push({
          path: "/OtherDanger/DangerTemplateDetail",
          query: {
            tCode: item.TCode,
            tRand: item.TRand,
            CompanyCode: this.CompanyCode,
            ctCode: this.form.CTCode,
          },
        });
      } else {
        this.$router.push(
          "/OtherDanger/DangerTemplateCheckResult?tCode=" +
            item.TCode +
            "&tRand=" +
            item.TRand
        );
      }
    },

    // 删除任务
    handdelete(){
      let that = this;
      Dialog.confirm({
        title: "询问",
        message: "您确定要删除当前检查任务吗?",
      })
        .then(() => {
          that.$axios
          .get("/OtherDangerCheckTaskJG/DeleteTask",{params:{ id: this.id }})
          .then((res)=>{
            that.$toast.success("删除成功！");
            that.$router.goRefresh(-1);
          })
        })
        .catch(() => {
          // on cancel
        });

    },

    handleClose() {
      let that = this;
      Dialog.confirm({
        title: "询问",
        message: "您确定要结束当前检查任务吗?",
      })
        .then(() => {
          that.$axios
          .post("/OtherDangerCheckTaskJG/End",{ id: that.id })
          .then((res)=>{
            that.$toast.success("结束成功！");
            that.$router.goRefresh(-1);
          })
        })
        .catch(() => {
          // on cancel
        });
    },
    // 生成报告
    Generatereport() {
      this.title = "生成整改报告(按任务)";
      this.$router.push({
        path: '/OtherDanger/Reportdetail?codes='+ this.form.CTCode,
        // path: "/OtherDanger/CorrectiveReport",
        query: { type: "Report", reportType: "2",},
      });
    },
    // 撤回任务
    withdraw() {
      let that = this;
      Dialog.confirm({
        title: "询问",
        message: "您确定要撤回此项任务吗?",
      })
        .then(() => {
          that.$axios
          .get("/OtherDangerCheckTaskJG/BackDanger",{params:{ id: this.id }})
          .then((res)=>{
            that.$toast.success("撤回成功！");
            that.$router.goRefresh(-1);
          })
        })
        .catch(() => {
          // on cancel
        });


    },
    // 不再验收
    Nomoreacceptance() {
      let that = this;
      Dialog.confirm({
        title: "询问",
        message: "您确定要不再验收此项任务吗?",
      })
        .then(() => {
          that.$axios
          .get("/OtherDangerCheckTaskJG/GiveupVerify",{params:{ id: this.id }})
          .then((res)=>{
            that.$toast.success("提交成功！");
            that.$router.goRefresh(-1);
          })
        })
        .catch(() => {
          // on cancel
        });

    }
  },
};
</script>

<style lang="less" scoped>
/*
        .main {
            height: 100vh;
        }
    */
.bottom-btns {
  margin-top: 10px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .submit-btn {
    width: 32%;
    height: 35px;
    font-size: 14px;
  }
  .delete-btn {
    width: 100%;
    height: 35px;
    font-size: 14px;
  }
}
.det_top_box {
  padding: 10px;
  background-color: #e8f1f8;
}

.detail_header {
  color: #ffffff;
  background: url("../../../assets/Images/AppIcon/image_riskunit_detail_bg.png");
  background-size: cover;
  padding: 10px;
  border-radius: 5px;
  /*background-color: #fff;*/

  .det_top {
    display: flex;
    justify-content: space-between;

    .dep_top_img {
      height: 20px;
      width: 20px;
      margin-right: 5px;
    }
  }

  .det_name {
    margin-top: 20px;
    text-align: center;
  }

  .det_location {
    text-align: center;
    margin-bottom: 20px;
  }
}

.det_tab {
  padding: 10px;
  .det_tab_item {
    padding: 10px 0;
    background-color: #fff;
    border-radius: 5px;
    margin-bottom: 10px;

    .det_tab_item_text {
      padding: 0 10px;
    }
  }
}
.text_box {
  padding: 10px;
  border-radius: 5px;
  /*background-color: #e8f1f8;*/
  margin-bottom: 10px;

  .text_top {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    .top_link {
      color: #1989fa;
    }
  }

  .text_item {
    display: flex;
    justify-content: space-between;
    margin-left: 10px;

    .item_link {
      color: #1989fa;
    }
  }

  .text_img {
    display: flex;
    align-items: center;

    .img_item {
      width: 33.3%;
      text-align: center;

      img {
        height: 25px;
        width: 25px;
        margin-bottom: 10px;
      }
    }
  }

  .text_history {
    display: flex;
    vertical-align: middle;
    margin-bottom: 10px;
  }

  .text_member {
    color: #1989fa;
    margin-bottom: 10px;
  }

  .text_total_img {
    display: flex;
    align-items: center;

    .img_item {
      width: 33.3%;
      text-align: center;

      .img_item_top {
        display: flex;
        vertical-align: middle;
        margin-bottom: 10px;
      }
      img {
        height: 15px;
        width: 15px;
        margin-right: 5px;
      }
    }
  }
  .text_record_list {
    .list_row {
      display: flex;
      justify-content: space-between;
      margin-bottom: 10px;
      > div {
        width: 33.3%;
      }
      .row_center {
        text-align: center;
      }
      .row_right {
        text-align: right;
      }
    }
  }
}
.operate_list {
  font-size: 12px;
  border: 1px solid #e8f1f8;
  .operate_row_first {
    padding: 10px;
    background-color: #e8f1f8;
    border-bottom: 1px solid #e8f1f8;
    margin-bottom: 10px;
  }
  .operate_row {
    padding: 10px;
    border-bottom: 1px solid #e8f1f8;
    /*margin-bottom: 10px;*/
  }
}
  .mls{
    margin-right: 5px;
  }
</style>
